﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using AutoMapper;

namespace Happy.AutoMapper
{
    /// <summary>
    /// 模型配置。
    /// </summary>
    public abstract class Profile<TSource, TTarget> : Profile
    {
        /// <summary>
        /// 执行配置。
        /// </summary>
        protected override void Configure()
        {
            var map = Mapper
                .CreateMap<TSource, TTarget>()
                .IgnoreNotPublicSetter();

            this.Configure(map);
        }

        /// <summary>
        /// 执行配置。
        /// </summary>
        protected virtual void Configure(IMappingExpression<TSource, TTarget> map)
        {
        }

        /// <summary>
        /// 配置名称。
        /// </summary>
        public override string ProfileName
        {
            get { return this.GetType().Name; }
        }
    }
}
